Make the tearoff functionality model/view, the tearoffmenuitem being the
authorMatthias Clasen <maclas@gmx.de>
Fri, 7 May 2004 04:43:56 +0000 (04:43 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 7 May 2004 04:43:56 +0000 (04:43 +0000)
Fri May  7 00:41:46 2004  Matthias Clasen  <maclas@gmx.de>

* gtk/gtktearoffmenuitem.h:
* gtk/gtktearoffmenuitem.c: Make the tearoff
functionality model/view, the tearoffmenuitem being
the view and the tearoff_state property of the menu
being the model.  (#101185, Owen Taylor)

* gtk/gtkmenu.c: Add a tearoff_state property.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkmenu.c
gtk/gtktearoffmenuitem.c
gtk/gtktearoffmenuitem.h

index 281384463c6cbc132970d3236e9335944f8f3baf..1c69d539452a2621077647f3f599ea0a96a0416e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Fri May  7 00:41:46 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtktearoffmenuitem.h: 
+       * gtk/gtktearoffmenuitem.c: Make the tearoff 
+       functionality model/view, the tearoffmenuitem being
+       the view and the tearoff_state property of the menu
+       being the model.  (#101185, Owen Taylor)
+
+       * gtk/gtkmenu.c: Add a tearoff_state property.
+
 Thu May  6 23:52:13 2004  Matthias Clasen  <maclas@gmx.de>
 
        Merge from 2.4:
index 281384463c6cbc132970d3236e9335944f8f3baf..1c69d539452a2621077647f3f599ea0a96a0416e 100644 (file)
@@ -1,3 +1,13 @@
+Fri May  7 00:41:46 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtktearoffmenuitem.h: 
+       * gtk/gtktearoffmenuitem.c: Make the tearoff 
+       functionality model/view, the tearoffmenuitem being
+       the view and the tearoff_state property of the menu
+       being the model.  (#101185, Owen Taylor)
+
+       * gtk/gtkmenu.c: Add a tearoff_state property.
+
 Thu May  6 23:52:13 2004  Matthias Clasen  <maclas@gmx.de>
 
        Merge from 2.4:
index 281384463c6cbc132970d3236e9335944f8f3baf..1c69d539452a2621077647f3f599ea0a96a0416e 100644 (file)
@@ -1,3 +1,13 @@
+Fri May  7 00:41:46 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtktearoffmenuitem.h: 
+       * gtk/gtktearoffmenuitem.c: Make the tearoff 
+       functionality model/view, the tearoffmenuitem being
+       the view and the tearoff_state property of the menu
+       being the model.  (#101185, Owen Taylor)
+
+       * gtk/gtkmenu.c: Add a tearoff_state property.
+
 Thu May  6 23:52:13 2004  Matthias Clasen  <maclas@gmx.de>
 
        Merge from 2.4:
index 281384463c6cbc132970d3236e9335944f8f3baf..1c69d539452a2621077647f3f599ea0a96a0416e 100644 (file)
@@ -1,3 +1,13 @@
+Fri May  7 00:41:46 2004  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtktearoffmenuitem.h: 
+       * gtk/gtktearoffmenuitem.c: Make the tearoff 
+       functionality model/view, the tearoffmenuitem being
+       the view and the tearoff_state property of the menu
+       being the model.  (#101185, Owen Taylor)
+
+       * gtk/gtkmenu.c: Add a tearoff_state property.
+
 Thu May  6 23:52:13 2004  Matthias Clasen  <maclas@gmx.de>
 
        Merge from 2.4:
index 180ac0b561d01184ab1c06639d9657c85d3f7610..8b456bd05f10e94b9c06f57b18f52375f3c22893 100644 (file)
@@ -110,6 +110,7 @@ enum {
 
 enum {
   PROP_0,
+  PROP_TEAROFF_STATE,
   PROP_TEAROFF_TITLE
 };
 
@@ -519,7 +520,22 @@ gtk_menu_class_init (GtkMenuClass *class)
                                                         P_("Tearoff Title"),
                                                         P_("A title that may be displayed by the window manager when this menu is torn-off"),
                                                         "",
-                                                        G_PARAM_READABLE | G_PARAM_WRITABLE));
+                                                        G_PARAM_READWRITE));
+
+  /**
+   * GtkMenu:tearoff-state:
+   *
+   * A boolean that indicates whether the menu is torn-off.
+   *
+   * Since: 2.6
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_TEAROFF_STATE,
+                                   g_param_spec_boolean ("tearoff-state",
+                                                        P_("Tearoff State"),
+                                                        P_("A boolean that indicates whether the menu is torn-off"),
+                                                        FALSE,
+                                                        G_PARAM_READWRITE));
 
   gtk_widget_class_install_style_property (widget_class,
                                           g_param_spec_int ("vertical-padding",
@@ -700,6 +716,9 @@ gtk_menu_set_property (GObject      *object,
   
   switch (prop_id)
     {
+    case PROP_TEAROFF_STATE:
+      gtk_menu_set_tearoff_state (menu, g_value_get_boolean (value));
+      break;
     case PROP_TEAROFF_TITLE:
       gtk_menu_set_title (menu, g_value_get_string (value));
       break;     
@@ -721,6 +740,9 @@ gtk_menu_get_property (GObject     *object,
   
   switch (prop_id)
     {
+    case PROP_TEAROFF_STATE:
+      g_value_set_boolean (value, gtk_menu_get_tearoff_state (menu));
+      break;
     case PROP_TEAROFF_TITLE:
       g_value_set_string (value, gtk_menu_get_title (menu));
       break;
@@ -1840,6 +1862,8 @@ gtk_menu_set_tearoff_state (GtkMenu  *menu,
          menu->tearoff_scrollbar = NULL;
          menu->tearoff_adjustment = NULL;
        }
+
+      g_object_notify (G_OBJECT (menu), "tearoff_state");
     }
 }
 
index 5df867befeb38efdfa29670fc8210ea9284ae747..79de16c3154d8ebab96822ea269fab249ef1f284 100644 (file)
@@ -96,7 +96,6 @@ gtk_tearoff_menu_item_class_init (GtkTearoffMenuItemClass *klass)
 static void
 gtk_tearoff_menu_item_init (GtkTearoffMenuItem *tearoff_menu_item)
 {
-  tearoff_menu_item->torn_off = FALSE;
 }
 
 static void
@@ -104,7 +103,7 @@ gtk_tearoff_menu_item_size_request (GtkWidget      *widget,
                                    GtkRequisition *requisition)
 {
   GtkTearoffMenuItem *tearoff;
-
+  
   tearoff = GTK_TEAROFF_MENU_ITEM (widget);
   
   requisition->width = (GTK_CONTAINER (widget)->border_width +
@@ -113,7 +112,7 @@ gtk_tearoff_menu_item_size_request (GtkWidget      *widget,
   requisition->height = (GTK_CONTAINER (widget)->border_width +
                         widget->style->ythickness) * 2;
 
-  if (tearoff->torn_off)
+  if (GTK_IS_MENU (widget->parent) && GTK_MENU (widget->parent)->torn_off)
     {
       requisition->height += ARROW_SIZE;
     }
@@ -166,7 +165,7 @@ gtk_tearoff_menu_item_paint (GtkWidget   *widget,
       else
        gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
 
-      if (tearoff_item->torn_off)
+      if (GTK_IS_MENU (widget->parent) && GTK_MENU (widget->parent)->torn_off)
        {
          gint arrow_x;
 
@@ -239,36 +238,19 @@ gtk_tearoff_menu_item_expose (GtkWidget      *widget,
   return FALSE;
 }
 
-static gint
-gtk_tearoff_menu_item_delete_cb (GtkMenuItem *menu_item, GdkEventAny *event)
-{
-  gtk_tearoff_menu_item_activate (menu_item);
-  return TRUE;
-}
-
 static void
 gtk_tearoff_menu_item_activate (GtkMenuItem *menu_item)
 {
   GtkTearoffMenuItem *tearoff_menu_item = GTK_TEAROFF_MENU_ITEM (menu_item);
 
-  tearoff_menu_item->torn_off = !tearoff_menu_item->torn_off;
-  gtk_widget_queue_resize (GTK_WIDGET (menu_item));
-
   if (GTK_IS_MENU (GTK_WIDGET (menu_item)->parent))
     {
       GtkMenu *menu = GTK_MENU (GTK_WIDGET (menu_item)->parent);
-      gboolean need_connect;
       
-       need_connect = (tearoff_menu_item->torn_off && !menu->tearoff_window);
-
-       gtk_menu_set_tearoff_state (GTK_MENU (GTK_WIDGET (menu_item)->parent),
-                                   tearoff_menu_item->torn_off);
-
-       if (need_connect)
-         g_signal_connect_swapped (menu->tearoff_window,
-                                   "delete_event",
-                                   G_CALLBACK (gtk_tearoff_menu_item_delete_cb),
-                                   menu_item);
+      gtk_menu_set_tearoff_state (GTK_MENU (GTK_WIDGET (menu_item)->parent),
+                                 !menu->torn_off);
     }
-}
+
+  gtk_widget_queue_resize (GTK_WIDGET (menu_item));
+ }
 
index ba5ff76a8a4f11f212829508b10ca0341fdbdb83..eb1ebdf34c3418bf741fc64265acb4fd3954ff99 100644 (file)
@@ -52,7 +52,7 @@ struct _GtkTearoffMenuItem
 {
   GtkMenuItem menu_item;
 
-  guint torn_off : 1;
+  guint _gtk_reserved : 1;
 };
 
 struct _GtkTearoffMenuItemClass